﻿#region License
// (c) Intergen.
// This source is subject to the Microsoft Public License (Ms-PL).
// Please see http://go.microsoft.com/fwlink/?LinkID=131993 for details.
// All other rights reserved.
#endregion

using System;
using System.Xml.Linq;
using System.Linq;
using System.Collections.Generic;

namespace TextGlow.Control.Model
{
  public class OpenDocumentStyle
  {
    public static readonly XNamespace Office = XNamespace.Get("urn:oasis:names:tc:opendocument:xmlns:office:1.0");
    public static readonly XNamespace Style = XNamespace.Get("urn:oasis:names:tc:opendocument:xmlns:style:1.0");
    public static readonly XNamespace Text = XNamespace.Get("urn:oasis:names:tc:opendocument:xmlns:text:1.0");

    private readonly string _name;
    private readonly IDictionary<string, string> _textProperties;

    public string Name
    {
      get { return _name; }
    }

    public IDictionary<string, string> TextProperties
    {
      get { return _textProperties; }
    } 

    public OpenDocumentStyle(XElement element)
    {
      _name = (string)element.Attribute(Style + "name");

      _textProperties = element.Elements(Style + "text-properties").Attributes()
        .ToDictionary(a => a.Name.LocalName, a => a.Value);
    }
  }
}
